import { RepeatMode } from './../model/task';
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'repeatMode'
})
export class RepeatModePipe implements PipeTransform {

  transform(value: RepeatMode, ...args: any[]): string {
    switch (value) {
      case RepeatMode.preDay: return '每日 ';
      case RepeatMode.preWeek: return '每周 ' + this.convertWeekDay(args[0]);
      case RepeatMode.preMonth: return '每月 ' + args[0] + '日';
      case RepeatMode.preQuarter: return '每季 第' + args[0] + '天';
      case RepeatMode.preHalfYear: return '每半年 第' + args[0] + '天';
      case RepeatMode.preYear: return '每年 第' + args[0] + '天';
    }
  }

  private convertWeekDay(daynum: number): string {
    switch (daynum) {
      case 1: return '周一';
      case 2: return '周二';
      case 3: return '周三';
      case 4: return '周四';
      case 5: return '周五';
      case 6: return '周六';
      case 7: return '周日';
      default: return '';
    }
  }

}
